package com.itheima.dao;


import com.itheima.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserDao {
    /**
     * 查询所有用户
     */
    @Select("select * from user")
    public List<User> findAll();

    /**
     * 根据用户id查询用户
     */
    @Select("select * from user where id=#{id}")
    public User findById(Integer id);

    /**
     * 添加用户
     */
    @Insert("insert into user(username,password,realname,gender,birthday) values(#{username},#{password},#{realname},#{gender},#{birthday})")
    public int save(User user);

    /**
     * 修改用户信息
     */
    @Update("update user set username=#{username},password=#{password},realname=#{realname},gender=#{gender},birthday=#{birthday} where id=#{id}")
    public  int update(User user);


    /**
     * 根据id删除用户
     */
    @Delete("delete from user where id = #{id}")
    public int delteById(Integer id);


    /**
     * 根据用户名和密码验证用户是否存在
     * @param username
     * @param password
     * @return
     */
    @Select("select * from user where  username=#{username} and password=#{password}")
    public  User findUserByUsernameAndPassword(@Param("username") String username, @Param("password") String password);

}
